var HtmlWebpackPlugin = require('html-webpack-plugin');
var HtmlWebpackPluginConfig = new HtmlWebpackPlugin({
	template: __dirname + '/index.html',
	filename: 'index.html',
	inject: 'head'
});
var NgMin = require('ng-annotate-webpack-plugin');
var ngMinConfig = new NgMin({
	add: true
});
var path = require('path');
var webpack = require('webpack');
var globalVariable = new webpack.DefinePlugin({
	'VERSION': JSON.stringify(require('./package.json').version)
});

module.exports = {
	entry: [
		'./module/index.js',
		'./node_modules/capture-selector/dist/u.min.js',
		'./lib/uiCodeMirror/src/ui-codemirror.js'
	],
	module: {
		loaders: [
			{
				test: /\.html$/,
				loader: 'ng-cache?module=probe&prefix=./[dir]/[dir]',
				include: path.resolve(__dirname, 'module')
			},
			{ 
				test: /\.css$/, 
				loader: 'style-loader!css-loader',
				include: [
					path.resolve(__dirname, './node_modules/oc-dialog/'),
					path.resolve(__dirname, './node_modules/codemirror/'),
					path.resolve(__dirname, 'module')
				]
			},
			{ 
				test: /\.png$/, 
				loader: 'url-loader?limit=100000&name=res/[hash].[ext]',
				include: path.resolve(__dirname, 'module')
			},
			{ 
				test: /\.jpg$/, 
				loader: 'url-loader?limit=100000&name=res/[hash].[ext]',
				include: path.resolve(__dirname, 'module')
			}
		],
		noParse: [
			/capture-selector\/dist\/u\.min\.js$/,
			/codemirror\/lib\/codemirror\.js$/
		]
	},
	output: {
		filename: 'bundle.js',
		path: path.resolve(__dirname, 'output')
	},
	plugins: [
		HtmlWebpackPluginConfig,
		ngMinConfig,
		globalVariable
	]
};
